<?php
declare(strict_types=1);
namespace Field;

class SysArticleConst
{
    public const pk='ArticleID';
    public const index=['ArticleID'];
	public const fields=['ArticleID','CateID','UserID','AttachID','Title','Tags','Points','Rmbs','IsTop','IsRecom','IsFree','IsVideo','IsImage','CreateAt','UpdateAt','FirstReplyID','LastReplyID','Status','Rank','IsDelete','Views','Likes','ReplyNum'];
	public const comment=['ArticleID'=>'文章ID','CateID'=>'任务类型','UserID'=>'用户','AttachID'=>'缩略图ID','Title'=>'文章标题','Tags'=>'标签1,2,3最少可以14个','Points'=>'单价','Rmbs'=>'单价','IsTop'=>'置顶（0=否，1=是）','IsRecom'=>'推荐（0=否，1=是）','IsFree'=>'是否免费(免费带积分为悬赏)','IsVideo'=>'视频（0=否，1=是）','IsImage'=>'图片（0=否，1=是）','CreateAt'=>'时间','UpdateAt'=>'更新','FirstReplyID'=>'第一帖ID','LastReplyID'=>'最后一帖ID','Status'=>'状态（0=禁止，1=启用）','Rank'=>'排序从小到大','IsDelete'=>'逻辑删除','Views'=>'访问量','Likes'=>'点赞量','ReplyNum'=>'回帖量'];
	/*
    * @Field ArticleID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 文章ID
    */
    public const ArticleID = 'ArticleID';
    /*
    * @Field CateID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 任务类型
    */
    public const CateID = 'CateID';
    /*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 用户
    */
    public const UserID = 'UserID';
    /*
    * @Field AttachID
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 缩略图ID
    */
    public const AttachID = 'AttachID';
    /*
    * @Field Title
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 文章标题
    */
    public const Title = 'Title';
    /*
    * @Field Tags
    * @Type varchar(160)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 标签1,2,3最少可以14个
    */
    public const Tags = 'Tags';
    /*
    * @Field Points
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 单价
    */
    public const Points = 'Points';
    /*
    * @Field Rmbs
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 单价
    */
    public const Rmbs = 'Rmbs';
    /*
    * @Field IsTop
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 置顶（0=否，1=是）
    */
    public const IsTop = 'IsTop';
    /*
    * @Field IsRecom
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 推荐（0=否，1=是）
    */
    public const IsRecom = 'IsRecom';
    /*
    * @Field IsFree
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 1
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 是否免费(免费带积分为悬赏)
    */
    public const IsFree = 'IsFree';
    /*
    * @Field IsVideo
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 视频（0=否，1=是）
    */
    public const IsVideo = 'IsVideo';
    /*
    * @Field IsImage
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 图片（0=否，1=是）
    */
    public const IsImage = 'IsImage';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field FirstReplyID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 第一帖ID
    */
    public const FirstReplyID = 'FirstReplyID';
    /*
    * @Field LastReplyID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 最后一帖ID
    */
    public const LastReplyID = 'LastReplyID';
    /*
    * @Field Status
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 状态（0=禁止，1=启用）
    */
    public const Status = 'Status';
    /*
    * @Field Rank
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 9999
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 排序从小到大
    */
    public const Rank = 'Rank';
    /*
    * @Field IsDelete
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 逻辑删除
    */
    public const IsDelete = 'IsDelete';
    /*
    * @Field Views
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 访问量
    */
    public const Views = 'Views';
    /*
    * @Field Likes
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 点赞量
    */
    public const Likes = 'Likes';
    /*
    * @Field ReplyNum
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 回帖量
    */
    public const ReplyNum = 'ReplyNum';
}

class SysArticleColumns
{
public  int $ArticleID;
   public  int $CateID=0;
   public  int $UserID;
   public  int $AttachID=0;
   public  string $Title;
   public  ?string $Tags='';
   public  int $Points=0;
   public  int $Rmbs=0;
   public  int $IsTop=0;
   public  int $IsRecom=0;
   public  int $IsFree=0;
   public  int $IsVideo=0;
   public  int $IsImage=0;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $FirstReplyID=0;
   public  int $LastReplyID=0;
   public  int $Status=0;
   public  int $Rank=0;
   public  int $IsDelete=0;
   public  int $Views=0;
   public  int $Likes=0;
   public  int $ReplyNum=0;
	public function toArray():array
	{
		return [
'ArticleID'=>$this->ArticleID,
    'CateID'=>$this->CateID,
    'UserID'=>$this->UserID,
    'AttachID'=>$this->AttachID,
    'Title'=>$this->Title,
    'Tags'=>$this->Tags,
    'Points'=>$this->Points,
    'Rmbs'=>$this->Rmbs,
    'IsTop'=>$this->IsTop,
    'IsRecom'=>$this->IsRecom,
    'IsFree'=>$this->IsFree,
    'IsVideo'=>$this->IsVideo,
    'IsImage'=>$this->IsImage,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'FirstReplyID'=>$this->FirstReplyID,
    'LastReplyID'=>$this->LastReplyID,
    'Status'=>$this->Status,
    'Rank'=>$this->Rank,
    'IsDelete'=>$this->IsDelete,
    'Views'=>$this->Views,
    'Likes'=>$this->Likes,
    'ReplyNum'=>$this->ReplyNum,        ];
	}
}

class SysArticleRow
{
	public SysArticleColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'ArticleID' => $this->data->ArticleID,
        'CateID' => $this->data->CateID,
        'UserID' => $this->data->UserID,
        'AttachID' => $this->data->AttachID,
        'Title' => $this->data->Title,
        'Tags' => $this->data->Tags,
        'Points' => $this->data->Points,
        'Rmbs' => $this->data->Rmbs,
        'IsTop' => $this->data->IsTop,
        'IsRecom' => $this->data->IsRecom,
        'IsFree' => $this->data->IsFree,
        'IsVideo' => $this->data->IsVideo,
        'IsImage' => $this->data->IsImage,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'FirstReplyID' => $this->data->FirstReplyID,
        'LastReplyID' => $this->data->LastReplyID,
        'Status' => $this->data->Status,
        'Rank' => $this->data->Rank,
        'IsDelete' => $this->data->IsDelete,
        'Views' => $this->data->Views,
        'Likes' => $this->data->Likes,
        'ReplyNum' => $this->data->ReplyNum, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysArticleColumns();
        isset($data['ArticleID']) && $this->data->ArticleID = (int)$data['ArticleID'];
           isset($data['CateID']) && $this->data->CateID = (int)$data['CateID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['Title']) && $this->data->Title = (string)$data['Title'];
           isset($data['Tags']) && $this->data->Tags = (string)$data['Tags'];
           isset($data['Points']) && $this->data->Points = (int)$data['Points'];
           isset($data['Rmbs']) && $this->data->Rmbs = (int)$data['Rmbs'];
           isset($data['IsTop']) && $this->data->IsTop = (int)$data['IsTop'];
           isset($data['IsRecom']) && $this->data->IsRecom = (int)$data['IsRecom'];
           isset($data['IsFree']) && $this->data->IsFree = (int)$data['IsFree'];
           isset($data['IsVideo']) && $this->data->IsVideo = (int)$data['IsVideo'];
           isset($data['IsImage']) && $this->data->IsImage = (int)$data['IsImage'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['FirstReplyID']) && $this->data->FirstReplyID = (int)$data['FirstReplyID'];
           isset($data['LastReplyID']) && $this->data->LastReplyID = (int)$data['LastReplyID'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
           isset($data['Rank']) && $this->data->Rank = (int)$data['Rank'];
           isset($data['IsDelete']) && $this->data->IsDelete = (int)$data['IsDelete'];
           isset($data['Views']) && $this->data->Views = (int)$data['Views'];
           isset($data['Likes']) && $this->data->Likes = (int)$data['Likes'];
           isset($data['ReplyNum']) && $this->data->ReplyNum = (int)$data['ReplyNum'];
    }
}
?>